import QtQuick 2.7  //2.0
import QtQuick.Controls 2.0
import QtQuick.Window 2.2
import QtQuick.Layouts 1.3

//平板模式布局
//1920*1080 1024*600

Rectangle {
    id:root
    color: "#00000000"
    property int adaptive_width: Screen.desktopAvailableWidth
    property int adaptive_height: Screen.desktopAvailableHeight

     MouseArea {
        anchors.fill: parent
        onClicked: {
            console.log("TableWindow:")
        }
    }

    SwipeView {
        id:menuSwpView
        width: adaptive_width
        height: adaptive_height/1.2
        Page {
            width: adaptive_width
            height: adaptive_height/1.2
            background: Rectangle {
                anchors.fill: parent
                opacity: 0
                color: "#00000000"
            }


            Rectangle{
                id: recttop
                width: adaptive_width
                height: adaptive_height/24
                color: "transparent"
            }

            //            AnimatedImage {
            //                id: img
            //                anchors.top: recttop.bottom
            //                anchors.topMargin: 60
            //                anchors.left: recttop.left
            //                anchors.leftMargin: 60
            //                source: "/images/son/dongtu.gif"
            //                width: adaptive_width/4
            //                height: adaptive_height/1.65
            //                opacity: 0.8
            //            }

            ListModel {
                id: menuListModel1
                ListElement {
                    _imageSource: "/images/son/application-table.png"
                    _text1: qsTr("")
                    _text2: qsTr("文本编辑")
                    _num: "1"
                    _qurl: "TextWindow.qml"
                }
                ListElement {
                    _imageSource: "/images/wvga/home/wash.png"
                    _text1: qsTr("智能洗衣机演示")
                    _text2: qsTr("演示")
                    _num: "1"
                    _qurl: "WashWindow.qml"
                }
                ListElement {
                    _imageSource: "images/wvga/home/information.png"
                    _text1: qsTr("系统信息")
                    _text2: qsTr("系统信息")
                    _num: "1"
                    _qurl: "InfoWindow.qml"
                }
                ListElement {
                    _imageSource: "images/son/folder-system.png"
                    _text1: qsTr("")
                    _text2: qsTr("系统设置")
                    _num: "1"
                    _qurl: "SettingsWindow.qml"
                }

                ListElement {
                    _imageSource: "images/wvga/home/filemanager.png"
                    _text1: qsTr("")
                    _text2: qsTr("文件管理")
                    _num: "1"
                    _qurl: "FileWindow.qml"
                }
                ListElement {
                    _imageSource: "images/wvga/home/contact.png"
                    _text1: qsTr("联系我们")
                    _text2: qsTr("联系我们")
                    _num: "1"
                    _qurl: "SupportWindow.qml"
                }
            }

            Grid{
                id: menuListGrid1
                anchors.top: recttop.bottom
                //anchors.topMargin: adaptive_height/24/*20*/
                anchors.topMargin: adaptive_height/22
                //                anchors.right: recttop.right
                //                anchors.rightMargin: adaptive_width/8
                columns:3
                rows:2
                //                    topPadding: 30
                columnSpacing: adaptive_width/8.33/*96;*/
               // rowSpacing: adaptive_height/19.2 /*25*/
                rowSpacing: adaptive_height/18
                anchors.horizontalCenter: parent.horizontalCenter

                Repeater{
                    model: menuListModel1
                    delegate: MenuListItem {
                        imageSource: _imageSource;
                        text1: _text1;
                        text2: _text2;
                        num: _num;
                        qurl: _qurl;
                    }
                }
            }
        }

        Page{
            width: adaptive_width
            height: adaptive_height/1.2
            background: Rectangle {
                anchors.fill: parent
                opacity: 0
                color: "#00000000"
            }
            Rectangle{
                id: recttop2
                width: adaptive_width
                height: adaptive_height/24
                color: "transparent"
            }

            ListModel{
                id: menuListModel2

                ListElement {
                    _imageSource: "/images/son/log.png"
                    _text1: qsTr("")
                    _text2: qsTr("pdf")
                    _num: "1"
                    _qurl: ""
                }
                ListElement {
                    _imageSource: "/images/son/83.png"
                    _text1: qsTr("")
                    _text2: qsTr("reader")
                    _num: "1"
                    _qurl: ""
                }
                ListElement {
                    _imageSource: "/images/son/safari.png"
                    _text1: qsTr("")
                    _text2: qsTr("safari")
                    _num: "1"
                    _qurl: ""
                }
                ListElement {
                    _imageSource: "/images/son/5e.png"
                    _text1: qsTr("")
                    _text2: qsTr("云盘")
                    _num: "1"
                    _qurl: ""
                }
                ListElement {
                    _imageSource: "/images/son/6e.png"
                    _text1: qsTr("")
                    _text2: qsTr("地图")
                    _num: "1"
                    _qurl: ""
                }
                ListElement {
                    _imageSource: "/images/son/iphoto.png"
                    _text1: qsTr("相册预览")
                    _text2: qsTr("相册")
                    _num: "1"
                    _qurl: "CameraWindow.qml"
                }
                ListElement {
                    _imageSource: "/images/son/quicktime.png"
                    _text1: qsTr("")
                    _text2: qsTr("检索")
                    _num: "1"
                    _qurl: "InterNetWindow.qml"
                }
                ListElement {
                    _imageSource: "/images/son/Help.png"
                    _text1: qsTr("帮助手册")
                    _text2: qsTr("帮助")
                    _num: "1"
                    _qurl: "HelpWindow.qml"
                }
                ListElement {
                    _imageSource: "/images/son/appdelete.png"
                    _text1: qsTr("垃圾回收站")
                    _text2: qsTr("回收站")
                    _num: "1"
                    _qurl: "PlayerWindow.qml"
                }

            }

            Grid{
                id: menuListGrid2
                anchors.top: recttop2.bottom
                anchors.topMargin: adaptive_height/22/*20*/
                columns:3
                rows:3
//                columnSpacing: adaptive_width/8.33 /*96;25*/
//                rowSpacing: adaptive_height/19.2 /*25*/
                columnSpacing: adaptive_width/8.33
                rowSpacing: adaptive_height/16
                anchors.horizontalCenter: parent.horizontalCenter

                Repeater{
                    model: menuListModel2
                    delegate: MenuListItem {
                        imageSource: _imageSource;
                        text1: _text1;
                        text2: _text2;
                        num: _num;
                        qurl: _qurl;
                    }
                }
            }
        }
    }

    PageIndicator{
        id: control
        count:menuSwpView.count
        currentIndex: menuSwpView.currentIndex
        anchors{
            bottom: menuSwpView.bottom
            horizontalCenter: parent.horizontalCenter
        }
        delegate: Rectangle {
            implicitWidth: 8
            implicitHeight: 8

            radius: width / 2
            color: "#eeeeee"

            opacity: index === control.currentIndex ? 0.95 : pressed ? 0.7 : 0.45

            Behavior on opacity {
                NumberAnimation {
                    duration: 200
                }
            }
        }
    }

    /*
    HomeButton {
        text: qsTr("toHOME")
        label.visible: false
        //source:"/images/son/switchcolor48.png"
        source:"/images/son/switch.png"
        width: 30
        height: 30
        glowRadius: 15
        //z: 2
        anchors {
            right:parent.right
            rightMargin: 200
            top: parent.top
            //bottomMargin: height * 0.5
            topMargin: 10
        }

        MouseArea {
            anchors.fill: parent
            enabled: true
            acceptedButtons: Qt.LeftButton //| Qt.RightButton
            cursorShape: Qt.PointingHandCursor
            onClicked: {
                console.log("switch HOME")
                mainWind.chooseWnd("HOME")
            }
            onPressAndHold: {
                console.log("long pressd")
                pressAndHoldInterval : 2000
                mainWind.chooseWnd("TABLET")
            }
        }



            onPressed: {
                var ret = pressedButtons & Qt.LeftButton
                var ret2 = pressedButtons & Qt.RightButton
                console.log(ret ? "left" : ret2 ? "right" : "other")
                if(ret2) {
                    console.log("onPressed")
                }
            }
            */
}



